import UIView from "../../../quick/core/ui/UIView";
import { Macro } from "../../../quick/defines/Macros";
import { Config } from "../config/Config";

const {ccclass, property} = cc._decorator;
/**
 * @description 该界面是一个切换显示方向的过渡界面
 * 界面尽量适配全屏
 * 使用Widget组件的alignMode属性,尽量设置为AlignMode.ALWAYS 方式
 * 以满足在显示过渡界面时，不至于露馅
 * 如果游戏支持横竖屏，建议弄两套UI，一套横屏，一套竖屏
 * 如果游戏不支持横竖屏，建议弄一套UI，无需要设置
 */
@ccclass
export default class ChangeView extends UIView {

    public static getPrefabUrl(){
        return "common/prefabs/ChangeView";
    }

    onShow(): void {
        if ( App.stageData.isLandscape ){
            const designResolutionSize = cc.size(Config.DESIGN_RESOLUTION_SIZE.height,Config.DESIGN_RESOLUTION_SIZE.width);
            App.stageData.designResolutionSize = designResolutionSize;
            // cc.view.setOrientation(cc.macro.ORIENTATION_PORTRAIT);
            cc.view.setDesignResolutionSize(designResolutionSize.width,designResolutionSize.height,cc.ResolutionPolicy.SHOW_ALL);
        }else{
            const designResolutionSize = cc.size(Config.DESIGN_RESOLUTION_SIZE.width,Config.DESIGN_RESOLUTION_SIZE.height);
            App.stageData.designResolutionSize = designResolutionSize;
            // cc.view.setOrientation(cc.macro.ORIENTATION_LANDSCAPE);
            cc.view.setDesignResolutionSize(designResolutionSize.width,designResolutionSize.height,cc.ResolutionPolicy.SHOW_ALL);
        }
        super.onShow();
        App.entryManager.enterBundle(Macro.BUNDLE_RESOURCES,{
            changeOrientation:true
        });
    }
}
